package org.wlw.web.controller;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.wlw.web.models.WebException;

@ControllerAdvice
public class ExceptionController {

    @ExceptionHandler(WebException.class)
    public String webExceptionHandler(Model model, WebException webException) {
        model.addAttribute("errorMsg", webException.getMessage());
        return "exception";
    }

    @ExceptionHandler(Exception.class)
    public String sysExceptionHandler(Model model, Exception e) {
        model.addAttribute("errorMsg", "发现系统级别的异常:" + e.getMessage());
        return "exception";
    }
}
